import 'package:binggo_bomb/commons/Constants.dart';
import 'package:binggo_bomb/page/bomb/BombStartWidget.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';

class BombIndexWidget extends StatefulWidget {
  const BombIndexWidget({super.key});

  @override
  State<BombIndexWidget> createState() => _BombIndexWidgetState();
}

class _BombIndexWidgetState extends State<BombIndexWidget> with SingleTickerProviderStateMixin {

  late TabController tabController;
  /// 已选中颜色
  int selectedIndex = 0;

  @override
  void initState() {
    super.initState();
    tabController = TabController(length: Constants.tabsColor.length, vsync: this);
  }

  @override
  void dispose() {
    tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('BingGo Bomb', style: TextStyle(color: Colors.black87),),
        backgroundColor: Colors.transparent,
        elevation: 0.0,
        centerTitle: true,
      ),
      body: Container(
        child: Column(
          children: [

            TabBar(
              labelStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
              unselectedLabelStyle: const TextStyle(fontSize: 16),
              isScrollable: false,
              controller: tabController,
              labelColor: Colors.blue,
              indicatorWeight: 3,
              indicatorPadding: const EdgeInsets.symmetric(horizontal: 10),
              unselectedLabelColor: Colors.grey,
              enableFeedback: true,
              // dragStartBehavior: DragStartBehavior.down,
              indicatorColor: Colors.orangeAccent,
              tabs: Constants.tabsName.map((e) => Tab(text: e,)).toList(),
              onTap: (v) {
                setState(() {
                  selectedIndex = v;
                });
                // getRadios(tabs[v]["code"].toString(), false);
                // _pageController.jumpToPage(v);
              },
            ),


            Expanded(
                child: TabBarView(
                  physics: NeverScrollableScrollPhysics(),//viewPage禁止左右滑动
                  controller: tabController,
                  children: Constants.tabsColor.map((e) => BombStartWidget(color: e)).toList(),
                  // children: [
                  //   BombStartWidget(color: selectedColor.toString(),),
                  //   Container(
                  //     child: Text("2"),
                  //   ),
                  //   Container(
                  //     child: Text("3"),
                  //   ),
                  //   Container(
                  //     child: Text("4"),
                  //   ),
                  // ],
                )
            ),




          ],


        ),
      ),
    );
  }






}
